<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>cosplay假胸（气球）尺码计算器</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
            color: #333;
        }
        
        h1 {
            color: #ff69b4;
            text-align: center;
            margin-bottom: 30px;
            font-size: 28px;
        }
        
        h2 {
            color: #ff69b4;
            border-bottom: 2px solid #ff69b4;
            padding-bottom: 5px;
        }
        
        p {
            line-height: 1.6;
            margin: 10px 0;
        }
        
        .info-box {
            background-color: #fffbe6;
            border-left: 4px solid #ffd700;
            padding: 15px;
            margin: 15px 0;
            border-radius: 5px;
        }
        
        input[type="text"], input[type="checkbox"] {
            padding: 10px;
            margin: 8px 0;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
            width: 200px;
            box-sizing: border-box;
        }
        
        input[type="text"]:focus {
            border-color: #ff69b4;
            outline: none;
            box-shadow: 0 0 5px rgba(255, 105, 180, 0.3);
        }
        
        button {
            background-color: #ff69b4;
            color: white;
            border: none;
            padding: 12px 20px;
            margin: 10px 5px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
        }
        
        button:hover {
            background-color: #ff5aa7;
        }
        
        #result {
            background-color: #e6f7ff;
            border: 1px solid #91d5ff;
            border-radius: 5px;
            padding: 15px;
            margin-top: 20px;
            font-weight: bold;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
            background-color: white;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        
        th, td {
            padding: 12px;
            text-align: center;
            border: 1px solid #ddd;
        }
        
        th {
            background-color: #ff69b4;
            color: white;
        }
        
        tr:nth-child(even) {
            background-color: #fff0f6;
        }
        
        .toggle-container {
            display: flex;
            align-items: center;
            margin: 15px 0;
        }
        
        .toggle-container input[type="checkbox"] {
            width: auto;
            margin-right: 10px;
        }
        
        .input-group {
            margin: 15px 0;
        }
        
        .input-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        
        .button-group {
            text-align: center;
        }
    </style>
</head>
<body>
    <!-- todo 添加使用胸围尺码代替上胸围计算 -->
    <h1 align="center">cosplay假胸（气球）尺码计算器</h1>
    <p>周长法适合快速估算，但误差较大（约±25%）
        横截面积+高度法更接近人体真实形状，误差可控制在±10%以内</p>
    <p>此工具用于男性coser计算用气球当女性胸部的尺码计算</p>
    <p>勾选使用罩杯表示使用预设的罩杯尺码参数计算</p>
    <h2>胸部罩杯尺码参考</h2>
    <input type="checkbox" onchange="switch_breast_table_visible()"><label for="">显示/隐藏表格</label><br/>
    <table border="1" id="breast_table">
        <tr>
            <th>罩杯</th>
            <th>差值范围 (cm)</th>
        </tr>
        <tr>
            <td>AA</td>
            <td>&lt; 7.5</td>
        </tr>
        <tr>
            <td>A</td>
            <td>7.5 - 10</td>
        </tr>
        <tr>
            <td>B</td>
            <td>10 - 12.5</td>
        </tr>
        <tr>
            <td>C</td>
            <td>12.5 - 15</td>
        </tr>
        <tr>
            <td>D</td>
            <td>15 - 17.5</td>
        </tr>
        <tr>
            <td>E</td>
            <td>17.5 - 20</td>
        </tr>
        <tr>
            <td>F</td>
            <td>20 - 22.5</td>
        </tr>
        <tr>
            <td>G</td>
            <td>22.5 - 25</td>
        </tr>
        <tr>
            <td>H</td>
            <td>25 - 27.5</td>
        </tr>
        <tr>
            <td>I</td>
            <td>27.5 - 30</td>
        </tr>
        <tr>
            <td>J</td>
            <td>30 - 32.5</td>
        </tr>
        <tr>
            <td>K</td>
            <td>32.5 - 35</td>
        </tr>
        <tr>
            <td>L</td>
            <td>35 - 37.5</td>
        </tr>
        <tr>
            <td>M</td>
            <td>37.5 - 40</td>
        </tr>
        <tr>
            <td>N</td>
            <td>40 - 42.5</td>
        </tr>
        <tr>
            <td>O</td>
            <td>42.5 - 45</td>
        </tr>
        <tr>
            <td>P</td>
            <td>45 - 47.5</td>
        </tr>
        <tr>
            <td>Q</td>
            <td>47.5 - 50</td>
        </tr>
        <tr>
            <td>R</td>
            <td>50 - 52.5</td>
        </tr>
        <tr>
            <td>S</td>
            <td>52.5 - 55</td>
        </tr>
        <tr>
            <td>T</td>
            <td>55 - 57.5</td>
        </tr>
        <tr>
            <td>U</td>
            <td>57.5 - 60</td>
        </tr>
        <tr>
            <td>V</td>
            <td>60 - 62.5</td>
        </tr>
        <tr>
            <td>W</td>
            <td>62.5 - 65</td>
        </tr>
        <tr>
            <td>X</td>
            <td>65 - 67.5</td>
        </tr>
        <tr>
            <td>Y</td>
            <td>67.5 - 70</td>
        </tr>
        <tr>
            <td>Z</td>
            <td>&gt;= 70</td>
        </tr>
    </table>
    <input id="underbust" type="text" placeholder="下胸围（cm）"><br/>
    <input id="upbust" type="text" placeholder="上胸围（cm）"><br/>
    <input id="kg" type="text" placeholder="体重（kg）"><br/>
    <input id="height" type="text" placeholder="身高（cm）"><br/>
    <button onclick="cal(1)">使用周长法计算</button>
    <button onclick="cal(2)">使用横截面积+突出高度计算</button>
    <p id="result">结果</p>
    <script>
        function cal(cal_type)
        {
            var underbust = document.getElementById("underbust").value;
            var upbust = document.getElementById("upbust").value;
            var kg = document.getElementById("kg").value;
            var height = document.getElementById("height").value;
            if(cal_type == 1)
            {
                calculateBalloonCircumference(underbust, upbust, kg, height);
            }
            else if(cal_type == 2)
            {
                var b = calculateBreastVolume(underbust, upbust, kg, height)
                document.getElementById("result").innerHTML = "人体参数：<br/>" + 
                "基础体积：" + b.humanVolume + "<br/>" +
                "组合模型体积：" + b.preciseVolume + "<br/>" +
                "气球周长：" + b.balloonCircumference + "<br/>" +
                "建议半径：" + b.suggestedRadius + "<br/>" +
                "建议高度：" + b.suggestedHeight;
            }
        }
       function calculateBalloonCircumference(underbust, overbust, weight, height) 
       {
        const cupSize = overbust - underbust; // 胸围差
        const standardWeight = height - 110; // 标准体重（身高-110）
        const overWeight = weight - standardWeight; // 超重体重
        
        // 乔群完整公式（含体重调整项）
        const volumePerBreast = 250 + 50 * cupSize + 20 * overWeight;
        
        // 球体周长计算
        const circumference = Math.cbrt(6 * Math.PI ** 2 * volumePerBreast);
        var C =  circumference.toFixed(2);
        document.getElementById("result").innerHTML = "每个气球应该充气到达的周长为：" + C + "cm";
        }
    function calculateBreastVolume(underbust, overbust, weight, height) 
    {
        const cupSize = overbust - underbust;
        const standardWeight = height - 110;
        const overWeight = weight - standardWeight;
        
        // 乔群公式计算基础体积（含体重调整）
        const baseVolume = 250 + 50 * cupSize + 20 * overWeight;
        
        // 转换为横截面积和高度（简化模型）
        // 假设半球体半径r和圆锥体高度h的比例为1:0.8
        const r = Math.cbrt((baseVolume * 3) / (2 * Math.PI + 0.8 * Math.PI));
        const h = r * 0.8;
        
        // 更精确的组合体积计算
        const preciseVolume = (2/3) * Math.PI * Math.pow(r, 3) + 
                                (1/3) * Math.PI * Math.pow(r, 2) * h;
        
        // 计算气球所需周长（假设用球体模拟）
        const balloonCircumference = Math.cbrt(6 * Math.PI ** 2 * preciseVolume).toFixed(2);
        
        // 返回人体参数和气球参数
        return {
            humanVolume: baseVolume.toFixed(0) + "cm³ (基础体积)",
            preciseVolume: preciseVolume.toFixed(0) + "cm³ (组合模型)",
            balloonCircumference: balloonCircumference + "cm (气球周长)",
            suggestedRadius: r.toFixed(1) + "cm (模拟乳房半径)",
            suggestedHeight: h.toFixed(1) + "cm (模拟乳房高度)"
        };
    }
    function switch_breast_table_visible(value)
    {
        var breast_table = document.getElementById("breast_table");
        var checkbox = event.target
        if(checkbox.checked)
        {
            breast_table.style.display = "table";
        }
        else{
            breast_table.style.display = "none";
        }
    }
    </script>
</body>
</html>